<template>
	<xh-page-wrapper
		ref="pageList"
		title="面料出库"
		:request="request"
		:deleteRequest="deleteRequest"
		@clickAdd="handleClickAdd"
		@clickItem="handleClickItem"
		@request="handleRequest"
		:columns="[
			{
				label: '检验编码',
				key: 'insCode',
				width: '100%',
				searchOrder: 3,
				isList: true,
			},
			{
				label: '产品名称',
				key: 'productName',
				valueMapList: productList,
				searchOrder: 2,
				isList: true,
			},
			{ label: '卷数', key: 'volumeNum', searchOrder: 4, isList: true },
			{
				label: '出库时间',
				key: 'boundTime',
				searchType: 'daterange',
				searchOrder: 1,
				isList: true,
			},
			{ label: '米数', key: 'meters', searchOrder: 5, isList: true },
			{
				label: '创建时间',
				key: 'createTime',
				search: false,
				width: '100%',
			},
		]"
		rowKey="fabricId"
	>
		<template #summary>
			<xh-summary-box
				:summaryData="summaryData"
				:labelList="[
					{ label: '总卷数', key: 'volumeNum' },
					{ label: '总米数', key: 'meters' },
				]"
			/>
		</template>
	</xh-page-wrapper>
</template>

<script>
import {
	getOutboundList,
	deleteFabric,
	getBoundSummary,
} from '@/api/purchase/fabric.js';
import mixins from '../mixins';

// 导入组件
export default {
	name: 'fabricDelivery',
	mixins: [mixins],
	data() {
		return {
			request: getOutboundList,
			deleteRequest: deleteFabric,
			summaryData: {},
		};
	},
	onShow() {
		this.$refs.pageList?._query();
	},
	methods: {
		handleClickAdd() {
			this.$nav.navigateTo('/subPurchaseManage/fabricDelivery/addForm');
		},
		handleClickItem(item) {
			this.$nav.navigateTo('/subPurchaseManage/fabricDelivery/editForm', item);
		},
		handleRequest(params) {
			getBoundSummary({ ...params, boundType: 0 }).then((res) => {
				const { data } = res;
				this.summaryData = data || {};
			});
		},
	},
};
</script>

<style scoped lang="scss"></style>
